square div

111

square div -

<div class='square-box'>
    <div class='square-content'>
        <h3>test</h3>
    </div>
</div>

<style>
.square-box{
    position: relative;
    width: 50%; /* You need to specify some width */
    overflow: hidden;
    background: rgba(0,0,0,0.1);
}
.square-box:before{
    content: "";
    display: block;
    padding-top: 100%;
}
.square-content{
    position:  absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    text-align: center;
    width: 100%;
}
</style>

how to make a square div in css -

.square {
    background-color: #000;
    width: 50vw;
    height: 50vw;
}
.square h1 {
    color: #fff;
}
/* It works */

Comments

Submit
0 Comments